<template>
  <div>
    <!-- 导航栏 -->
    <Banner></Banner>
    <!-- 九宫格排布 -->
    <Jiugongge></Jiugongge>
    <!-- 滚动消息栏 -->
    <Scroll></Scroll>
    <!-- 主题游 -->
    <Theme></Theme>
    <!-- 切换周边游/当地游 -->
    <Qiehuan></Qiehuan>
    <!-- 滑动导航 -->
    <SwiperTabs></SwiperTabs>
    <!-- 秒杀 -->
    <Miaosha :spikeList="adressData.spikeList" lang="1"></Miaosha>
    <!-- 底部切换栏 -->
    <FooterTabs></FooterTabs>
  </div>
</template>

<script>
import Banner from "./home/Banner";
import Jiugongge from "./home/Jiugongge";
import Theme from "./home/Theme";
import Qiehuan from "./home/Qiehuan";
import SwiperTabs from "./home/SwiperTabs";
import Miaosha from "./home/Miaosha";
import FooterTabs from "./home/FooterTabs";
import Scroll from "./home/Scroll";
import { mapState } from "vuex";
export default {
  components: {
    Banner,
    Jiugongge,
    Theme,
    Qiehuan,
    SwiperTabs,
    Miaosha,
    FooterTabs,
    Scroll
  },
  props: {},
  data() {
    return {
      adressData: {},
      currentAdress: ""
    };
  },
  watch: {},
  computed: {
    ...mapState({
      selectedCity: state => state.City.selectedCity
    })
  },
  methods: {
    http() {
      let that = this;
      this.axios.get("http://localhost:8080//api/dataHome.json").then(res => {
        res.data.data.forEach(item => {
          if (item.city == this.$store.state.City.selectedCity) {
            // console.log(item);
            that.adressData = item;
          }
        });
      });
    }
  },
  created() {},
  mounted() {
    this.currentAdress = this.selectedCity;
    this.http();
  },
  activated() {
    if (this.selectedCity != this.currentAdress) {
      this.http();
      this.currentAdress = this.selectedCity;
    }
  }
};
</script>
<style lang="less" scoped>
</style>